package com.harry.decoupling.impl.proxy;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.harry.basis.BaseGeneric;
import com.harry.decoupling.defi.module.RestfulApi;
import com.harry.decoupling.defi.proxy.RestfulApiProxy;
import com.harry.decoupling.defi.tool.DataExchange;

@Component
public class RestfulProxyImplApi implements RestfulApiProxy {

	@Autowired
	DataExchange de;

	@Override
	public void getone(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).getone(params, request, response, data);
	}

	@Override
	public void getlist(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).getlist(params, request, response, data);
	}

	@Override
	public void exists(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).exists(params, request, response, data);
	}

	@Override
	public void post(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).post(params, request, response, data);
	}

	@Override
	public void patch(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).patch(params, request, response, data);
	}

	@Override
	public void delete(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).delete(params, request, response, data);
	}

	@Override
	public void getexcel(String srcName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		impl(srcName).getexcel(params, request, response, data);
	}

	private static RestfulApi<?> impl(String srcName) throws Exception {
		return BaseGeneric.beanOf(RestfulApi.class, srcName);
	}
}
